package client

import (
	"github.com/go-resty/resty/v2"
	"time"
)

var httpClient = resty.New()

func init() {
	retryAfter := func(client *resty.Client, resp *resty.Response) (time.Duration, error) {
		return 2 * client.RetryWaitTime, nil
	}
	httpClient.SetHeader("User-Agent", "gbox-one-machine/1.0")
	httpClient.SetRetryCount(5)
	httpClient.SetRetryWaitTime(time.Millisecond * 500)
	httpClient.SetRetryMaxWaitTime(time.Second * 2)
	httpClient.SetRetryAfter(retryAfter)
}

// GetHTTPClient get client
func GetHTTPClient() *resty.Client {

	return httpClient
}